﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace ABELGX
{
    /// <summary>
    /// WindowMotor.xaml 的交互逻辑
    /// </summary>
    public partial class WindowMotor : Window
    {
        public Car Car { get; private set; }
        List<UserControlDriverItem> driverItems;
        public WindowMotor()
        {
            InitializeComponent();
            driverItems = new List<UserControlDriverItem>
            {
                Driver1,
                Driver2,
                Driver3,
                Driver4,
            };
        }
        public void SetCar(Car car)
        {
            Car = car;
            if (Car == null)
            {
                return;
            }
            MoveSpeed.SetSensor( car.InfoDriver.MoveSpeed);
            RotationSpeed.SetSensor(car.InfoDriver.RotationSpeed);
            DistanceLeft.SetSensor(car.InfoDriver.DistanceLeft);
            DistanceRight.SetSensor(car.InfoDriver.DistanceRight);

            for (int i = 0;i< driverItems.Count; i++)
            {
                if (car.InfoDriver.Items.Count > i)
                {
                    driverItems[i].Visibility = Visibility.Visible;
                    driverItems[i].SetDriver(car.InfoDriver.Items[i]);
                }
                else
                {
                    driverItems[i].Visibility = Visibility.Hidden;
                }
            }
        }
    }
}
